package com.mvp.lt.airlineview.map;

import android.text.TextUtils;


import com.amap.api.maps.model.LatLng;
import com.mvp.lt.airlineview.base.DataListUtils;
import com.mvp.lt.airlineview.base.LatLngTypeConverter;
import com.mvp.lt.airlineview.utils.FileUtils;

import java.util.List;

import static com.mvp.lt.airlineview.utils.FileUtils.PHOTOGRAPHY_LINE_DATA;

/**
 * user caoyu
 * date 2021/1/13
 * time 11:23
 * 建图航拍实体类
 */
public class PhotographBean {
    private int id;
    private String onLineId;
    private String userId;
    private String updateTime;
    private String mapImgPath;
    private String address;
    private int cameraType;
    private String cameraName;
    private double baseGsd;
    private double focalLength;
    private String name;//名称
    private String projectName;//工程名
    private String projectId;//工程id
    private int takeType;//拍摄模式
    private int flyHeight;//飞行高度
    private int takeoffSpeed;//起飞速度
    private int routeSpeed;//航线速度
    //完成动作 0：悬停 ，1：自动返航 ，2：原地降落，3：返回航线起点
    private int finishActionType;
    //完成动作 0：悬停 ，1：自动返航 ，2：原地降落，3：返回航线起点
    private String finishActionTypeName;
    private int diskOverlapRatio;//旁向重叠率 100
    private int courseOverlapRatio;//航向重叠率 90
    private int mainCourseAngle;//主航线角度 360
    private int tiltAngle;//倾斜角度
    private int margin;//边距
    private String latLngPath;
    private int dataType;
    private int dataSources;    //0 1 2
    private List<LatLng> mCenterLatLng;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public int getTakeType() {
        return takeType;
    }

    public void setTakeType(int takeType) {
        this.takeType = takeType;
    }

    public int getFlyHeight() {
        return flyHeight;
    }

    public void setFlyHeight(int flyHeight) {
        this.flyHeight = flyHeight;
    }

    public int getTakeoffSpeed() {
        return takeoffSpeed;
    }

    public void setTakeoffSpeed(int takeoffSpeed) {
        this.takeoffSpeed = takeoffSpeed;
    }

    public int getRouteSpeed() {
        return routeSpeed;
    }

    public void setRouteSpeed(int routeSpeed) {
        this.routeSpeed = routeSpeed;
    }

    public int getFinishActionType() {
        return finishActionType;
    }

    public void setFinishActionType(int finishActionType) {
        this.finishActionType = finishActionType;
    }

    public String getFinishActionTypeName() {
        return finishActionTypeName;
    }

    public void setFinishActionTypeName(String finishActionTypeName) {
        this.finishActionTypeName = finishActionTypeName;
    }

    public int getDiskOverlapRatio() {
        return diskOverlapRatio;
    }

    public void setDiskOverlapRatio(int diskOverlapRatio) {
        this.diskOverlapRatio = diskOverlapRatio;
    }

    public int getCourseOverlapRatio() {
        return courseOverlapRatio;
    }

    public void setCourseOverlapRatio(int courseOverlapRatio) {
        this.courseOverlapRatio = courseOverlapRatio;
    }

    public int getMainCourseAngle() {
        return mainCourseAngle;
    }

    public void setMainCourseAngle(int mainCourseAngle) {
        this.mainCourseAngle = mainCourseAngle;
    }

    public int getMargin() {
        return margin;
    }

    public void setMargin(int margin) {
        this.margin = margin;
    }


    public String getOnLineId() {
        return onLineId;
    }

    public void setOnLineId(String onLineId) {
        this.onLineId = onLineId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public String getMapImgPath() {
        return mapImgPath;
    }

    public void setMapImgPath(String mapImgPath) {
        this.mapImgPath = mapImgPath;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getCameraType() {
        return cameraType;
    }

    public void setCameraType(int cameraType) {
        this.cameraType = cameraType;
    }

    public String getCameraName() {
        return cameraName;
    }

    public void setCameraName(String cameraName) {
        this.cameraName = cameraName;
    }

    public double getBaseGsd() {
        return baseGsd;
    }

    public void setBaseGsd(double baseGsd) {
        this.baseGsd = baseGsd;
    }

    public double getFocalLength() {
        return focalLength;
    }

    public void setFocalLength(double focalLength) {
        this.focalLength = focalLength;
    }

    public String getLatLngPath() {
        return latLngPath;
    }

    public void setLatLngPath(String latLngPath) {
        this.latLngPath = latLngPath;
    }

    public int getDataSources() {
        return dataSources;
    }

    public void setDataSources(int dataSources) {
        this.dataSources = dataSources;
    }

    public List<LatLng> getCenterLatLng() {
        return mCenterLatLng;
    }

    public void setCenterLatLng(List<LatLng> centerLatLng) {
        mCenterLatLng = centerLatLng;
    }

    public int getDataType() {
        return dataType;
    }

    public void setDataType(int dataType) {
        this.dataType = dataType;
    }

    public int getTiltAngle() {
        return tiltAngle;
    }

    public void setTiltAngle(int tiltAngle) {
        this.tiltAngle = tiltAngle;
    }

    /**
     * 初始化数据
     */
    public void initData(int dataType) {
        PhotographBean bandWayLineBean = new PhotographBean();
        if (dataType == 0) {
            if (bandWayLineBean == null) {
                setName("新建建图航拍飞行1");
            } else {
                setName("新建建图航拍飞行" + (bandWayLineBean.getId() + 1));
            }
        } else {
            if (bandWayLineBean == null) {
                setName("新建倾斜摄影飞行1");
            } else {
                setName("新建倾斜摄影飞行1" + (bandWayLineBean.getId() + 1));
            }
        }
        setUserId("");
        setMapImgPath("");
        setMargin(0);
        setTiltAngle(60);
        setMainCourseAngle(270);
        setAddress("");
        setOnLineId("");
        setDiskOverlapRatio(80);
        setCourseOverlapRatio(80);
        setFlyHeight(100);
        setTakeoffSpeed(10);
        setRouteSpeed(6);
        setProjectId("");
        setProjectName("");
        setLatLngPath("");
        setDataType(dataType);
        setTakeType(DataListUtils.getInstance().getTakePhotoTypeList().get(0).getId());
        setCameraType(DataListUtils.getInstance().getCameraList().get(0).getId());
        setBaseGsd(DataListUtils.getInstance().getCameraList().get(0).getGsd());
        setFocalLength(DataListUtils.getInstance().getCameraList().get(0).getFocalLength());
        setFinishActionType(DataListUtils.getInstance().getFinishActionDataBeans().get(1).getId());
        setFinishActionTypeName(DataListUtils.getInstance().getFinishActionDataBeans().get(1).getName());
        setCameraName(DataListUtils.getInstance().getCameraList().get(0).getName());
        setDataSources(0);
    }


    /**
     * 经纬度轨迹
     *
     * @return
     */
    public List<LatLng> readLatlngData() {
        LatLngTypeConverter latLngTypeConverter = new LatLngTypeConverter();
        String contentLatLngs = FileUtils.readFileText(getLatLngPath());
        return latLngTypeConverter.stringToSomeObjectList(contentLatLngs);
    }

    /**
     * 保存经纬度轨迹点
     *
     * @param latLngs
     */
    public void saveLatLngData(List<LatLng> latLngs) {
        if (getLatLngPath() == null || TextUtils.isEmpty(getLatLngPath())) {
            String path = FileUtils.getDir(PHOTOGRAPHY_LINE_DATA);
            String name = System.currentTimeMillis() + "";
            setLatLngPath(path + name);
        }
        LatLngTypeConverter latLngTypeConverter = new LatLngTypeConverter();
        String latlngString = latLngTypeConverter.someObjectListToString(latLngs);
        FileUtils.writeFile(latlngString, getLatLngPath());
    }
}
